//
//  AddDepositCardViewController.m
//  WBBaseProject
//
//  Created by 吴斌 on 2018/3/13.
//  Copyright © 2018年 吴斌. All rights reserved.
//

#import "AddDepositCardViewController.h"
#import "InputView.h"
#import "ChooseView.h"
#import "VerificationCodeView.h"
#import "AddCreditCardViewController.h"
#import "DeviceSafetyViewController.h"
#import "SetTradPwdViewController.h"
#import <YYLabel.h>
#import <NSAttributedString+YYText.h>

@interface AddDepositCardViewController ()

/** scrollView */
@property (nonatomic,strong) UIScrollView *scrollView;
/** <#注释#> */
@property (nonatomic,strong) YYLabel *agreeLb;

@end

@implementation AddDepositCardViewController

#pragma mark - 生命周期 Life Circle
- (void)viewDidLoad {
    [super viewDidLoad];
    self.navigationItem.title = @"添加储蓄卡";
    [self setupUI];
}

- (void)setupUI
{
    WB_WeakSelf(self)
    UIScrollView *scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, kScreenHeight - kNavigationBarHeight)];
    scrollView.contentSize = CGSizeMake(kScreenWidth, kScreenHeight - kNavigationBarHeight + 1);
    scrollView.bounces = YES;
    scrollView.backgroundColor = WB_RGBColor(240, 240, 240);
    [self.view addSubview:scrollView];
    
    UILabel *tipLb = [[UILabel alloc] initWithFrame:CGRectMake(15, 0, kScreenWidth - 15, 30)];
    tipLb.text = @"添加成功后，该卡将设置为您的自动还款储蓄卡";
    tipLb.font = [UIFont systemFontOfSize:12];
    tipLb.textColor = WB_RGBColor(128, 128, 128);
    [scrollView addSubview:tipLb];
    
    InputView *view1 = [[NSBundle mainBundle] loadNibNamed:NSStringFromClass([InputView class])  owner:self options:nil].firstObject;
    view1.titleLb.text = @"持卡人";
    view1.inputTF.text = @"吴斌";
    view1.inputTF.enabled = NO;
    view1.frame = CGRectMake(0, 30, kScreenWidth, kRowHeight);
//    _branchTF = view3.inputTF;
    [scrollView addSubview:view1];
    
    ChooseView *view2 = [[NSBundle mainBundle] loadNibNamed:NSStringFromClass([ChooseView class])  owner:self options:nil].firstObject;
    view2.titleLb.text = @"银行";
    view2.inputTF.text = @"吴斌";
    view2.frame = CGRectMake(0, 30 + kRowHeight, kScreenWidth, kRowHeight);
    //    _branchTF = view3.inputTF;
    [scrollView addSubview:view2];
    
    InputView *view3 = [[NSBundle mainBundle] loadNibNamed:NSStringFromClass([InputView class])  owner:self options:nil].firstObject;
    view3.titleLb.text = @"银行卡号";
    view3.lineView.hidden = YES;
    view3.frame = CGRectMake(0, 30 + 2 * kRowHeight, kScreenWidth, kRowHeight);
    //    _branchTF = view3.inputTF;
    [scrollView addSubview:view3];
    
    InputView *view4 = [[NSBundle mainBundle] loadNibNamed:NSStringFromClass([InputView class])  owner:self options:nil].firstObject;
    view4.titleLb.text = @"银行预留手机号码";
//    view4.inputTF.text = @"吴斌";
    view4.frame = CGRectMake(0, 30 + 3 * kRowHeight + kBlankHeight, kScreenWidth, kRowHeight);
    //    _branchTF = view3.inputTF;
    [scrollView addSubview:view4];
    
    VerificationCodeView *view5 = [[NSBundle mainBundle] loadNibNamed:NSStringFromClass([VerificationCodeView class])  owner:self options:nil].firstObject;
//    view5.titleLb.text = @"银行预留手机号码";
    //    view4.inputTF.text = @"吴斌";
    view5.frame = CGRectMake(0, 30 + 4 * kRowHeight + kBlankHeight, kScreenWidth, kRowHeight);
    //    _branchTF = view3.inputTF;
    [scrollView addSubview:view5];
    
    UIButton *sureBtn = [Factory customButtonWithTitle:@"确定"];
    sureBtn.frame = CGRectMake(55, 35 + CGRectGetMaxY(view5.frame), kScreenWidth - 110, 50);
    [sureBtn addTarget:self action:@selector(sureClick:) forControlEvents:UIControlEventTouchUpInside];
    [scrollView addSubview:sureBtn];
                         
    YYLabel *agreeLb = [[YYLabel alloc] initWithFrame:CGRectMake(5, CGRectGetMaxY(sureBtn.frame) + 5, kScreenWidth, 21)];
    NSMutableAttributedString *text = [[NSMutableAttributedString alloc] initWithString:@"确定即默认您已同意自动还款协议"];
    text.yy_font = [UIFont systemFontOfSize:12];
    text.yy_color = WB_RGBColor(178, 178, 178);
    [text yy_setTextHighlightRange:NSMakeRange(9, 6) color:WB_RGBColor(53, 134, 255) backgroundColor:[UIColor whiteColor] tapAction:^(UIView * _Nonnull containerView, NSAttributedString * _Nonnull text, NSRange range, CGRect rect) {
        NSLog(@"点击了");
        DeviceSafetyViewController *vc = [[DeviceSafetyViewController alloc] init];
        [weakself.navigationController pushViewController:vc animated:YES];
    }];
    agreeLb.attributedText = text;
    
//    agreeLb.font = [UIFont systemFontOfSize:12];
//    agreeLb.text = @"确定即默认您已同意自动还款协议";
    agreeLb.textAlignment = NSTextAlignmentCenter;
    [scrollView addSubview:agreeLb];
}

- (void)sureClick:(UIButton *)sender
{
    SetTradPwdViewController *vc = [[SetTradPwdViewController alloc] init];
    vc.isAddPwd = YES;
    [self.navigationController pushViewController:vc animated:YES];
}


@end
